import 'package:flutter/material.dart';

class CustomDialog extends StatelessWidget {
  final String title;
  final String? description;
  final String leftButtonText;
  final String rightButtonText;
  final VoidCallback? onLeftPressed;
  final VoidCallback? onRightPressed;

  const CustomDialog({
    super.key,
    required this.title,
    this.description,
    required this.leftButtonText,
    required this.rightButtonText,
    this.onLeftPressed,
    this.onRightPressed,
  });

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        // 蒙层
        Positioned.fill(
          child: Container(
            color: Colors.black.withValues(alpha: 0.5),
          ),
        ),
        // 内容区域
        Center(
          child: Container(
            width: 345,
            padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 25),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(20),
            ),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                SizedBox(height: 15),
                // 标题
                Text(
                  title,
                  style: const TextStyle(
                    fontSize: 17,
                    color: Color(0xFF000000),
                  ),
                  textAlign: TextAlign.center,
                ),
                SizedBox(height: 25),
                // 描述（可选）
                if (description != null)
                  Padding(
                    
                    padding: const EdgeInsets.only(bottom: 25),
                    child: Text(
                      description!,
                      style: const TextStyle(
                        fontSize: 15,
                        color: Colors.black,
                      ),
                      textAlign: TextAlign.center,
                    ),
                  ),
                // 按钮区域
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    // 左侧按钮
                    SizedBox(
                      width: 140,
                      height: 48,
                      child: ElevatedButton(
                        style: ElevatedButton.styleFrom(
                          backgroundColor: const Color(0xFFEDEFEF),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(15),
                          ),
                        ),
                        onPressed: onLeftPressed,
                        child: Text(
                          leftButtonText,
                          style: const TextStyle(
                            fontSize: 15,
                            color: Color(0xFF505050),
                          ),
                        ),
                      ),
                    ),
                    const SizedBox(width: 15),
                    // 右侧按钮
                    SizedBox(
                      width: 140,
                      height: 48,
                      child: ElevatedButton(
                        style: ElevatedButton.styleFrom(
                          backgroundColor: const Color(0xFF5D5FEE),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(15),
                          ),
                        ),
                        onPressed: onRightPressed,
                        child: Text(
                          rightButtonText,
                          style: TextStyle(
                            fontSize: 15,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }
}